package com.system.dao.impl;



import com.system.config.Jdbc;
import com.system.dao.UserFunctionData;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public class UserFunctionDataMapper implements UserFunctionData {
    private final Jdbc jb;

    public UserFunctionDataMapper() {
        this.jb = new Jdbc();
    }


    // 添加评论
    @Override
    public boolean addContext(String email,String name, String text) {
        try {
            String publishTime = new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date());
            String sql = "INSERT INTO publish_tb(email,name,text, publishTime,contentAmount,isShow) VALUES(?,?,?,?,?,?)";
            PreparedStatement pstmt = jb.prepareStatement(sql);
            pstmt.setString(1,email);
            pstmt.setString(2,name);
            pstmt.setString(3,text);
            pstmt.setString(4,publishTime);
            pstmt.setInt(5,0);
            pstmt.setInt(6,0);
            int i = pstmt.executeUpdate();
            return true;
        }catch (SQLException e)
        {
            throw new RuntimeException(e);
        }
    }
}
